package com.pn.controller;

import com.pn.entity.purchaseAmount;
import com.pn.service.StatisticsService;
import com.pn.utils.Result;
import com.pn.vo.InStoreAndOutStoreVo;
import com.pn.vo.StoreCountVo;
import com.pn.vo.purchaseAmountVo;
import com.pn.vo.todayDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;

@RestController
@RequestMapping("/statistics")
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;

    //统计仓库库存
    @GetMapping("/store-invent")
    public Result storeInvent(){
        List<StoreCountVo> storeCountVos = statisticsService.queryStoreCount();

        return Result.ok(storeCountVos);
    }

    //今日数据
    @GetMapping("todayData")
    public Result todayData(){
        //获得当天的开始时间
        LocalDateTime begin = LocalDateTime.now().with(LocalTime.MIN);
        //获得当天的结束时间
        LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);

        todayDataVo todayDataVo = statisticsService.todayData(begin,end);

        return Result.ok(todayDataVo);
    }

    //采购占比
    @GetMapping("purchase-amount")
    public Result purchaseAmount(){
        List<purchaseAmount> purchaseAmountlist  = statisticsService.purchaseAmount();
        return Result.ok(purchaseAmountlist);
    }

    //2024年出入库信息
    @GetMapping("InStoreAndOutStore")
    public Result InStoreAndOutStore(){
        InStoreAndOutStoreVo inStoreAndOutStoreVo = statisticsService.InStoreAndOutStore();
        return Result.ok(inStoreAndOutStoreVo);
    }
}
